package com.nbaplayer.info;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class PlayerInfoAdapter extends BaseAdapter{
	
    	Context context;
    	
    	String[][] player_info, bio;
    	
    	int[] profile_pics = { R.drawable.act_chris_bosh, R.drawable.act_jose_barea, R.drawable.act_kobe_bryant, R.drawable.act_lebron_james, R.drawable.act_demarcus_cousins };
    	
    	public PlayerInfoAdapter(Context c, String[][] info, String[][] bio)
    	{
    		this.context = c;
    		this.player_info = new String[info.length][];
    		this.player_info = info;
    		this.bio = new String[bio.length][];
    		this.bio = bio;
    	}
    	
		public int getCount() {
			return this.player_info.length;
		}

		public Object getItem(int position) {
			return this.player_info[position];
		}

		public long getItemId(int arg0) {
			return 0;
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			OnePlayer one_player;
			LayoutInflater layoutinflater= ((Activity)context).getLayoutInflater();
			
			if(convertView==null)  
			{  
				one_player = new OnePlayer();  
				convertView = layoutinflater.inflate( R.layout.one_player_info, null );  
				one_player.name = (TextView) convertView.findViewById( R.id.txt_name );
				one_player.position = (TextView) convertView.findViewById( R.id.txt_position );
				one_player.number = (TextView) convertView.findViewById( R.id.txt_number );
				one_player.img = (ImageView) convertView.findViewById( R.id.profile_pic );
				one_player.background = (TextView) convertView.findViewById( R.id.background );
				one_player.personal = (TextView) convertView.findViewById( R.id.personal );
				convertView.setTag(one_player);
			}  
			else
				one_player=(OnePlayer)convertView.getTag();

			one_player.name.setText( this.player_info[position][0] );
			one_player.position.setText( this.player_info[position][1] );
			one_player.number.setText( this.player_info[position][2] );
			one_player.img.setImageResource( profile_pics[position] );
			one_player.background.setText( this.bio[position][0] );
			one_player.personal.setText( this.bio[position][1] );
			return convertView;

		}

}
